package cn.initcap.concurrency.concurrency.singleton;

import cn.initcap.concurrency.annoations.Recomend;
import cn.initcap.concurrency.annoations.ThreadSafe;

/**
 * 饿汉模式{静态代码块,一定要注意代码的顺序，}
 *
 * @author initcap
 * @date Created in 2018/6/14 PM12:26.
 */
@ThreadSafe
@Recomend
public class SingletonStaticBlock {

    private static SingletonStaticBlock instance = null;

    static {
        instance = new SingletonStaticBlock();
    }

    /**
     * 私有构造函数
     */
    private SingletonStaticBlock() {

    }

    /**
     * 静态的工厂方法
     */
    public static SingletonStaticBlock getInstance() {
        return instance;
    }

}
